let app = getApp()
Component({
    properties: {
 
      },
      data:{
        show_cancel: !1,
        search_val: "",
        search_placeholder: "请输入关键词",
        search_type: "",
        curr_kw: "",
        search_keyword: [],
        list: [],
        page_path: "pages/search/index",
        page: 1,
        end: !1,
        init: !0,
        loading: !1
      },
    lifetimes: {
        attached: function () {
           
       }
      },
    methods: {
      cancel:function() {
        this.setData({
          search_val:'',
          list:[]
        })
      },
      search_val:function(e){
        this.setData({
          search_val:e.detail.value
        })
        if(e.detail.value.length>0){
          this.search_data()
        }else{
          this.setData({
            list:[]
          })
        }
      },
      search_data:function() {
        var that=this
        wx.request({
          url: app.globalData.siteroot,
          data: {
            do:'search_data',
            search_val:that.data.search_val,
            search_type:'product',
            page:1
          },
          success: function(res) {
             if(res.data.info.length>0){
              that.setData({
                list:res.data.info,
                init:true
              })
             }else{
              that.setData({
                list:[],
                init:true
              })
             }
          }
        })
      }
    }
});
